Lua Scripting
To automate the simulation, you can use Lua scripting with OMSimulator. More information about the lua scripting support can be found in the User Guide.oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./BouncingBall-lua/")
-- oms_setWorkingDirectory("./BouncingBall-lua/")
oms_newModel("model")
oms_addSystem("model.root", oms_system_sc)
oms_addSubModel("model.root.BouncingBall", "BouncingBall.fmu")
oms_setResultFile("model", "results.mat")
oms_instantiate("model")
oms_initialize("model")
oms_simulate("model")
oms_terminate("model")
oms_delete("model")
Run the script using the following command:OMSimulator.exe <script>.lua
Example output:info: maximum step size for 'model.root': 0.001000
info: Result file: results.mat (bufferSize=1)
info: Final Statistics for 'model.root':
NumSteps = 552 NumRhsEvals = 557 NumLinSolvSetups = 32
NumNonlinSolvIters = 556 NumNonlinSolvConvFails = 0 NumErrTestFails = 1
The result file can be plotted using OMEdit, OMPlot, or any other tool that supports .mat or .csv files. OpenModelica includes OMPlot, a simple tool for quickly visualizing result files:OMPlot.exe --plotAll --filename=results.mat